package com.xiaoqi.intentstudy;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;

public class HomeActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.home_activity);
        Button homeButton = findViewById(R.id.home_button);
        homeButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                // 创建Intent对象
                Intent intent = new Intent();
                // 设置Intent动作
                intent.setAction(Intent.ACTION_MAIN);
                // 设置Intent种类
                intent.addCategory(Intent.CATEGORY_HOME);
                // 将Intent传递给Activity
                startActivity(intent);
            }
        });

    }
}